package com.gitee.l0km.thrift.swift2thrift.generator;

import java.util.Map;

import com.beust.jcommander.IStringConverter;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;

public class MapConverter implements IStringConverter<Map<String,String>> {

	public MapConverter() {
	}

	@Override
	public Map<String,String> convert(String value) {
		String[] entrys = value.split(";");
		Builder<String,String> builder = ImmutableMap.builder();
		for(String entry:entrys){
			String[] e = entry.split(":");
			if(e.length == 2){
				builder.put(e[0], e[1]);	
			}			
		}
		return builder.build();
	}

}
